<!DOCTYPE html>
<html lang="ZH-cn">
<head>
    <meta charset="UTF-8">
    <title>超级管理员</title>
    <style>
        body{width: 1200px;margin:0 auto;font-family: "Simsun",Tahoma,Arial,sans-serif;font-size: 14px;color:#000;}
        .mydetail{width: 1200px;padding-bottom:50px }
        table {background-color: transparent;border-collapse: collapse;border-spacing: 0;}
        .mydetail th, .mydetail td {border: 1px solid #e2e2e2;}
        .mydetail td,.mydetail th {text-align: center;padding: 10px 5px;}
        .tal{text-align: left;}
        .tac{text-align: center;}
        li{list-style: none}
        .search-con{height: 50px;line-height: 50px;background:#f3f3f3;padding: 5px 30px;margin-bottom: 10px}
        .search-con input{margin-right: 30px;}
        .search-con span{color: red;font-weight: bold;}
        .STYLE2 {font-size: medium}
        .ml10{margin-left: 50px;color:red;}
        .ml20{margin-left: 20px}
        .mt20{margin-top: 20px}
        .tit_01{color: #333;font-size: 16px;}
        .txt_01 li{line-height: 30px}
        .txt_01 a{color: #000}
        .txt_01 a:hover{color: #6f67dc}
        a:link {text-decoration: none;}
        a:visited {text-decoration: none;}
        a:hover {text-decoration: none;}
        a:active {text-decoration: none;}
        .aaa{display: inline-block;height: 40px;line-height: 40px;vertical-align: top;}
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="jquery-3.3.1.js"></script>
    <link type="text/css" rel="stylesheet" href="css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="css/bootstrap-grid.min.css">
</head>
<body style="margin: 0 auto">
<!--头部设置-->
<table width="1200" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td height="100"><a href="http://www.ego-buy.com.cn/"><img src="image/bg11.jpg" alt="0" width="1200" height="76" border="0"></a></td>
    </tr>
    <tr>
        <td height="50"><img src="image/bg00.jpg" alt="0" width="1200" height="87"></td>
    </tr>
    <tr>
        <td height="50"><a href="index.php" class="STYLE2" style="margin-left:10px;">返回列表</a></td>
    </tr>
</table>

<div class="container">
    <h4 class="h5">更改用户权限组</h4>
    <!--<div class="col-md-12 row">-->
        <!--<div class="input-group">-->
            <!--<input type="text" class='form-control' name="search_text" placeholder="请输入用户名或电话号码查找....">-->
            <!--<span class="input-group-btn">-->
                    <!--<input class="btn btn-primary" name="search" type="button" value="搜索">-->
            <!--</span>-->
        <!--</div>-->
    <!--</div>-->
    <div class="container table-responsive" style="border: 1px solid red;width: 100%;height: 550px;padding: 5px">
        <table class="table table-hover table-striped table-bordered table-condensed">
            <tr class="text-center">
                <th>ID</th>
                <th>Name</th>
                <th>E-mail</th>
                <th>Phone</th>
                <th>Company_Name</th>
                <th>Rule_id</th>
                <th>Rate</th>
                <th>Operation</th>
            </tr>
            <tbody id="t-body">
                <?php foreach($admin_data as $key=>$list){ ?>
                    <tr>
                        <td><?php echo $list['id'] ?></td>
                        <td><?php echo $list['names'] ?></td>
                        <td><?php echo $list['email'] ?></td>
                        <td><?php echo $list['phone'] ?></td>
                        <td style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;"><?php echo $list['company_name'] ?></td>
                        <td><input type="text" style="width: 80px" list="rule" disabled name="rule_id" value="<?php echo $list['rule_id'] ?>"></td>
                        <td><input type="text" style="width: 80px" disabled name="rate" value="<?php echo $list['rate'] ?>"></td>
                        <td>
                            <input class="btn btn-primary" name="modify" type="button" id="<?php echo $list['id']?>" value="修改用户权限&税率">
                            <input class="btn btn-primary" style="display: none" name="change" type="button"  value="提交修改">
                        </td>
                    </tr>
                <?php } ?>
            </tbody>
            <datalist id="rule">
                <option value="1" >1</option>
                <option value="2" >2</option>
                <option value="3" >3</option>
                <option value="4" >4</option>
                <option value="5" >5</option>
            </datalist>
        </table>
    </div>
    <span style="font-size: 0.85em;color: red">*Rule_id：1为供应商，2为管理员或需求商，3为审批领导，4为归档人，5为超级管理员</span>

</div>
<script>
    //搜索功能
    $("input[name='search']").click(function () {
        console.log('search');
        var search_text = $("input[name='search_text']").val();
        $.ajax({
            url:'super_admin_tool.php',
            method: "post",
            dataType:'json',
            data: {
                'action' : 'search',
                'value' : search_text
            },
            success: function (res) {
                if (res.code == 200) {
                    console.log('success');
                    $("#t-body").empty();
                    console.log(typeof res.data,res.data);
                    $.each(res.data,function (i, item) {
                        let temp = "<tr>";
                        temp = temp + "<td>"+item['id']+"</td>";
                        temp = temp + "<td>"+item['names']+"</td>";
                        temp = temp + "<td>"+item['email']+"</td>";
                        temp = temp + "<td>"+item['phone']+"</td>";
                        temp = temp + "<td>"+item['company_data']+"</td>";
                        temp = temp + "<td><input type='text' style='width: 80px' list='rule' name='rule_id' value='"+item['rule_id']+"'></td>";
                        temp = temp + "<td><input class='btn btn-primary' name='modify' type='button' id='"+item['id']+"' value='修改用户权限'>";
                        temp = temp +"<input class=\"btn btn-primary\" style=\"display: none\" name=\"change\" type=\"button\"  value=\"提交修改\"></td>";
                        temp = temp + "</tr>";
                        $("#t-body").append(temp);
                    });
                }
            }
        });
    });

    //修改用户权限
    $("input[name='modify']").click(function () {
        var id = $(this).attr('id');
        console.log('用户id: '+id);
        $(this).parent().parent().children().children("input[name='rule_id']").removeAttr('disabled');
        $(this).parent().parent().children().children("input[name='rate']").removeAttr('disabled');
        $(this).parent().children("input[name='change']").css('display','inherit');
        $(this).css('display','none');
        $("input[name='change']").click(function () {
            var rule_id = $(this).parent().parent().children().children("input[name='rule_id']").val();
            var rate = $(this).parent().parent().children().children("input[name='rate']").val();
            console.log("rule_id: "+rule_id);
            console.log("rate: "+rate);
            $.ajax({
                url: "super_admin_tool.php",
                method: 'post',
                dataType: 'json',
                data: {
                    'action' : 'change',
                    'id' : id,
                    'rule_id' : rule_id,
                    'rate' : rate
                },
                success: function (res) {
                    if (res.code == 200) {
                        $(this).css('display','inherit');
                        $(this).parent().children("input[name='change']").css('display','none');
                        window.location.reload();
                    }
                }
            });
        });
        $(this).parent().parent().children().children("input[name='rule_id']").attr('disabled');
        $(this).parent().parent().children().children("input[name='rate']").attr('disabled');
    });
</script>
<div class="container" id="pane" style="display:none;z-index: 5;height: 600px;border: gold;position: absolute;top: 270px;left: 30px;background-color: lightgrey">
    <div class="container row">
        <div class="col-md-4 input-group">
            <span class="input-group-addon" id="addon11">FID:</span>
            <input type="text" class="form-control" aria-describedby="addon11" placeholder="金蝶内码标识">
        </div>
        <div class="col-md-4 input-group">
            <span class="input-group-addon" id="addon12">会员类型</span>
            <input type="text" class="form-control" aria-describedby="addon12">
        </div>
        <div class="col-md-4 input-group">
            <span class="input-group-addon" id="addon13">名称</span>
            <input type="text" class="form-control" aria-describedby="addon13">
        </div>
    </div>
    <div class="container row">
        <div class="col-md-4 input-group">
            <span class="input-group-addon" id="addon21">邮箱</span>
            <input type="text" class="form-control" aria-describedby="addon11">
        </div>
        <div class="col-md-4 input-group">
            <span class="input-group-addon" id="addon22">电话</span>
            <input type="text" class="form-control" aria-describedby="addon12">
        </div>
        <div class="col-md-4 input-group">
            <span class="input-group-addon" id="addon23">密码</span>
            <input type="password" class="form-control" aria-describedby="addon13">
        </div>
    </div>
    <div class="container row">
        <div class="col-md-4 input-group">
            <span class="input-group-addon" id="addon31">编码</span>
            <input type="text" class="form-control" aria-describedby="addon11" placeholder="供应商编码">
        </div>
        <div class="col-md-4 input-group">
            <span class="input-group-addon" id="addon32">名称</span>
            <input type="text" class="form-control" aria-describedby="addon12" placeholder="企业名称">
        </div>
        <div class="col-md-4 input-group">
            <span class="input-group-addon" id="addon33">地址</span>
            <input type="password" class="form-control" aria-describedby="addon13" placeholder="企业地址">
        </div>
        <div class="col-md-4 input-group">
            <span class="input-group-addon" id="addon34">人数</span>
            <input type="password" class="form-control" aria-describedby="addon13" placeholder="企业人数">
        </div>
    </div>
</div>

<!--底部设置-->
<table width="1200" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td height="100" align="center" valign="bottom"><p><span class="STYLE8 STYLE3"><a rel="nofollow" target="_blank" href="http://www.ego-buy.com.cn/faqListDetail.do?parent_id=108&id=112">集团简介 | </a><a rel="nofollow" target="_blank" href="http://www.ego-buy.com.cn/faqListDetail.do?parent_id=108&id=143">广告服务</a> | <a rel="nofollow" target="_blank" href="http://www.ego-buy.com.cn/faqListDetail.do?parent_id=108&id=115">版权信息 |</a> <a rel="nofollow" target="_blank" href="http://www.ego-buy.com.cn/faqListDetail.do?parent_id=108&id=113">商家入驻 </a> | <a rel="nofollow" target="_blank" href="http://www.ego-buy.com.cn/faqListDetail.do?parent_id=108&id=114">新闻动态</a></span></p></td>
    </tr>
    <tr>
        <td height="30" align="center"><span class="STYLE3">Copyright © 2014-2015 ego-buy.com.cn All Rights Reserved 粤ICP备15026826号</span></td>
    </tr>
</table>
</body>
</html>